import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../home_children/keep_live_widget.dart';
import '../home_children/un_keep_live_widget.dart';

///
/// 那时我们有梦
/// 关于文学
/// 关于爱情
/// 关于穿越世界的旅行
/// 如今我们深夜饮酒
/// 杯子碰到一起
/// 都是梦破碎的声音
///
class PhonePage extends StatefulWidget {
  final String title;

  const PhonePage({super.key, required this.title});

  @override
  State<PhonePage> createState() => _PhonePageState();
}

class _PhonePageState extends State<PhonePage> {
  int curPageIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // 三段式布局的顶部导航栏
      appBar: AppBar(
        title: Text(widget.title),
      ),
      // 三段式布局的主体
      body: IndexedStack(
        index: curPageIndex,
        children: [
          KeepLiveWidget(),
          KeepLiveWidget(),
        ],
      ),
      // 三段式布局的底部导航栏
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: '第一个布局',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.business),
            label: '第二个布局',
          )
        ],
        currentIndex: curPageIndex,
        onTap: (index) {
          setState(() {
            curPageIndex = index;
          });
        },
      ),
    );
  }
}
